package kr.co.graviti.common.util;

import java.math.BigInteger;
import java.security.MessageDigest;

public class Crypto {
	public Crypto() {}
	public static String encryption(String text) throws Exception  {
	
		String retVal = "";
		try{
			MessageDigest md = MessageDigest.getInstance("MD5");
			byte[] messageDigest = md.digest(text.getBytes());
			BigInteger number = new BigInteger(1,messageDigest);
			
			String hashtext = number.toString(16);
			while(hashtext.length() < 32){
				hashtext = "0" + hashtext;
			}
			retVal = hashtext;
		}catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			retVal = "";
		}
	  return retVal;
    }
}
